/*
 * Product Router
 * @Author: chiangbt@geoportal.cn 
 * @Date: 2019-05-09 10:22:41 
 * @Last Modified by:   chiangbt@geoportal.cn 
 * @Last Modified time: 2019-05-09 10:22:41 
 */
const express = require('express');
const router = express.Router();

const jwt = require('express-jwt');
const productController = require('../controllers/productController');

/**
 * 获取products对象
 */
router.get('/products', productController.products_get_all);

/**
 * 创建新的product对象
 */
router.post('/products', jwt({
    secret: process.env.SecretOrPublicKey
}), productController.create_product);

/**
 * 获取指定id的product对象
 */
router.get('/products/:id', productController.get_product_by_id);

/**
 * 更新指定id的product对象
 */
router.patch('/products/:id', jwt({
    secret: process.env.SecretOrPublicKey
}), productController.update_product);

/**
 * 删除指定id的product对象
 */
router.delete('/products/:id', jwt({
    secret: process.env.SecretOrPublicKey
}), productController.delete_product);

module.exports = router;